// request.js
import axios from 'axios'
import { useAuthStore } from '@/stores/auth'
import { setupInterceptors } from '@/utils/interceptors'

const service = axios.create({
    baseURL: import.meta.env.VITE_API_BASE_URL || "https://kiku001.top/officialWebSite",
    timeout: 10000
})

export function request(config) {
    const authStore = useAuthStore()

    if (authStore.token) {
        config.headers = config.headers || {}
        config.headers.Authorization = `Bearer ${authStore.token}`
    }
    return service(config)
}

setupInterceptors(service)
